class UserData {
  final int id;
  final String name;
  final String email;
  final int age;
  final String phone;

  UserData({
    required this.id,
    required this.name,
    required this.email,
    required this.age,
    required this.phone,
  });

  factory UserData.fromJson(Map<String, dynamic> json) {
    return UserData(
      id: json['id'] ?? 0,
      name: json['name'] ?? '',
      email: json['email'] ?? '',
      age: json['age'] ?? 0,
      phone: json['phone'] ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'email': email,
      'age': age,
      'phone': phone,
    };
  }
}

class LoginRequest {
  final String username;
  final String password;

  LoginRequest({
    required this.username,
    required this.password,
  });

  Map<String, dynamic> toJson() {
    return {
      'username': username,
      'password': password,
    };
  }
}

class LoginResponse {
  final String token;
  final int userId;
  final String name;

  LoginResponse({
    required this.token,
    required this.userId,
    required this.name,
  });

  factory LoginResponse.fromJson(Map<String, dynamic> json) {
    return LoginResponse(
      token: json['token'] ?? '',
      userId: json['user_id'] ?? 0,
      name: json['name'] ?? '',
    );
  }
}

class EncryptedRequest {
  final String data;

  EncryptedRequest({required this.data});

  Map<String, dynamic> toJson() {
    return {
      'data': data,
    };
  }
}

class EncryptedResponse {
  final bool success;
  final String data;
  final String message;

  EncryptedResponse({
    required this.success,
    required this.data,
    required this.message,
  });

  factory EncryptedResponse.fromJson(Map<String, dynamic> json) {
    return EncryptedResponse(
      success: json['success'] ?? false,
      data: json['data'] ?? '',
      message: json['message'] ?? '',
    );
  }
}
